﻿// *****************************************************************
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
// *****************************************************************

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Bio.TestAutomation.Util;
using Bio.Util.Logging;
using Bio.Distributions;

namespace Bio.TestAutomation.Distributions
{
    /// <summary>
    /// Bvt Test Cases for ContinousStatistics Class
    /// </summary>
    [TestClass]
    public class ContinousStatisticsBvtTestCases
    {
        #region Constructor

        /// <summary>
        /// Static constructor to open log and make other settings needed for test
        /// </summary>
        static ContinousStatisticsBvtTestCases()
        {
            Trace.Set(Trace.SeqWarnings);
            if (!ApplicationLog.Ready)
            {
                ApplicationLog.Open("bio.automation.log");
            }
        }

        #endregion Constructor

        #region ContinuousStatistics Bvt Test Cases

        /// <summary>
        /// validates the GetMissingInstance property
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateContinuousStatisticsGetMissingInstance()
        {
            ContinuousStatistics continousStat = ContinuousStatistics.GetMissingInstance;
            Assert.IsTrue(continousStat.IsMissing());
        }

        /// <summary>
        /// validates the Equals method
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateContinuousStatisticsEquals()
        {
            SufficientStatistics suffStat = ContinuousStatistics.GetInstance(2);
            ContinuousStatistics continousStat = ContinuousStatistics.GetMissingInstance;
            Assert.IsFalse(continousStat.Equals(suffStat));

            suffStat = (SufficientStatistics)continousStat;
            Assert.IsTrue(continousStat.Equals(suffStat));

            continousStat = ContinuousStatistics.GetInstance(1.23565);
            suffStat = (SufficientStatistics)continousStat;
            Assert.IsTrue(continousStat.Equals(suffStat));

            object suffStatObj = (object)continousStat;
            Assert.IsTrue(continousStat.Equals(suffStat));
        }

        /// <summary>
        /// validates the TryParse method
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateContinuousStatisticsTryParse()
        {
            SufficientStatistics result = null;
            ContinuousStatistics continousStat = ContinuousStatistics.GetInstance(1.25658);
            Assert.IsTrue(ContinuousStatistics.TryParse("1.25658", out result));
            Assert.IsTrue(continousStat.Equals(result));
        }

        /// <summary>
        /// validates properties of the ContinuousStatistics class
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateContinuousStatisticsProperties()
        {
            ContinuousStatistics continousStat = ContinuousStatistics.GetInstance(1.25658);
            Assert.AreEqual(1.25658, continousStat.Value);
        }

        /// <summary>
        /// validates the ToString method
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateContinuousStatisticsToString()
        {
            ContinuousStatistics continousStat1 = ContinuousStatistics.GetInstance(1);
            ContinuousStatistics continousStat2 = ContinuousStatistics.GetMissingInstance;
            Assert.AreEqual(continousStat1.Value.ToString((IFormatProvider)null), continousStat1.ToString());
            Assert.AreEqual("Missing", continousStat2.ToString());
        }

        #endregion ContinuousStatistics Bvt Test Cases
    }
}
